package com.yanfan.maintain.quartz;

public enum CronField {
    HOUR(1, "时", "0 0 * * * ?"),
    WEEK(2, "周", "0 0 ? * MON *"),
    DAY(3, "日", "0 0 12 * * ?");

    private final int code;
    private final String description;
    private final String expression;

    CronField(int code, String description, String expression) {
        this.code = code;
        this.description = description;
        this.expression = expression;
    }

    public int getCode() {
        return code;
    }

    public String getDescription() {
        return description;
    }

    public String getExpression() {
        return expression;
    }

    public static CronField getByCode(int code) {
        for (CronField field : values()) {
            if (field.code == code) {
                return field;
            }
        }
        return null;
    }
}
